<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Cache-control" content="private, must-revalidate" />
<title>flash无刷新多图片上传</title>
<script type="text/javascript">
	var path='/Public/swfu';
	var url='/index.php/Admin/Upload';
</script>
<script type="text/javascript" src="/Public/swfu/js/jquery.js"></script>
<script type="text/javascript" src="/Public/swfu/js/swfupload.js"></script>
<script type="text/javascript" src="/Public/swfu/js/handlers.js"></script>
<link href="/Public/swfu/css/default.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="/Public/admin/layui/css/layui.css" media="all">
<link rel="stylesheet" type="text/css" href="/Public/admin/global.css" media="all">
<link rel="stylesheet" type="text/css" href="/Public/admin/css/adminstyle.css" media="all">
<script type="text/javascript">
	var swfu;
	window.onload = function () {
		swfu = new SWFUpload({
			upload_url: "/index.php/Admin/Upload/upload",
			post_params: {"PHPSESSID": "<?php echo session_id();?>"},
			file_size_limit : "2 MB",
			file_types : "*.jpg;*.png;*.gif;*.bmp;*.jpeg",
			file_types_description : "JPG Images",
			file_upload_limit : "<?php echo ($num); ?>",
			file_queue_error_handler : fileQueueError,
			file_dialog_complete_handler : fileDialogComplete,
			upload_progress_handler : uploadProgress,
			upload_error_handler : uploadError,
			upload_success_handler : uploadSuccess,
			upload_complete_handler : uploadComplete,
			button_image_url : "/Public/swfu/images/upload.png",
			button_placeholder_id : "spanButtonPlaceholder",
			button_width: 113,
			button_height: 45,
			button_text : '',
			button_text_style : '.spanButtonPlaceholder { font-family: Helvetica, Arial, sans-serif; font-size: 14pt;} ',
			button_text_top_padding: 0,
			button_text_left_padding: 0,
			button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
			button_cursor: SWFUpload.CURSOR.HAND,
			flash_url : "/Public/swfu/swf/swfupload.swf",
			custom_settings : {
				upload_target : "divFileProgressContainer"
			},
			debug: false
		});
	};
</script>
</head>
<body>
	<div style="width: 610px;min-height: 200px; border: 1px solid #e1e1e1; font-size: 12px; padding: 10px;margin:20px auto">
		<div id="divFileProgressContainer"></div>
		<div id="thumbnails">
			<ul id="pic_list" style="margin: 5px;"></ul>
			<div style="clear: both;"></div>
		</div>
	</div>
	<div style="width:115px;margin-left: 30px; float: left;"><span id="spanButtonPlaceholder"  ></span></div>
	<div class="layui-input-block" style="width: 140px; margin-right:30px;float: right;">
      <a class="layui-btn" onclick="submyform('<?php echo ($fieldname); ?>')">提交</a>
      <a class="layui-btn layui-btn-primary" onclick="pclose()">取消</a>
    </div>

	<script>
	var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
	function submyform(fieldname){
		var a = new Array();
		b="";
		$("#pic_list input[type='hidden']").each(function(i=0){
			var id = $(this).val();
			a[i] = id;
			i++;
		});
		$("#pic_list img.content").each(function(i=0){
			var src = $(this).attr('src');
			b = b+"<img src='"+src+"'>";
			i++;
		});
		var _iframe = window.parent;
        var _img =_iframe.document.getElementById(fieldname);
        _img.value = a;
        var _div =_iframe.document.getElementById("div"+fieldname);
        _div.innerHTML=b;
        parent.layer.close(index);
	}
	function pclose() {
		parent.layer.close(index);
	}
	</script>
</body>
</html>